<%@ page language="java" pageEncoding="UTF-8" contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/header.jsp" %>
<%-- <link rel="stylesheet" href="${ctx}/extra/custom/datepicker.css" /> --%>
<script type="text/javascript">

var scripts = [null, null];
$('.page-content-area').ace_ajax('loadScripts', scripts, function() {
	
		//时间插件切换目录后失效，加载前清下$("#ui-datepicker-div")
		$("#ui-datepicker-div").remove();
		
		var startTime = $("#startDate").datepicker({
			 maxDate:new Date()
		}).datepicker('setDate', getLastMonth(new Date())); 
		 
		var endTime = $("#endDate").datepicker({
			 maxDate:new Date()
		}).datepicker('setDate' , new Date());
		 
		 function setDate() {
	        setTimeout(function() {
	        	startTime.datepicker("setDate", getLastMonth(new Date()));
	        	endTime.datepicker("setDate", new Date());
	        }, 200); 
	    } 
		
		setDate();
		
		$("#query_form").on("reset",setDate);
		 
		 
		$('#startDate').on('change', function () {
			$("#startDate").valid();
	    });
		$('#endDate').on('change', function () {
			$("#startDate").valid();
	    });
		
		$("#result_list_div").load("${ctx}/log/toLogList", $("#query_form").serialize());	
		 
	});
	
	
	$("#query_form").validate({
	    errorElement: 'div',
	    errorClass: 'help-block',
	    focusInvalid: false,
	    /* onfocusout: function(element){
	        $(element).valid();
	    }, */ 
	    rules: {
	       startDate:{
	          required:false,
	          isDate10:true,
	          compareDate:"#endDate",
	       },
	       endDate:{
		      required:false,
		      isDate10:true
		   }
	    },
	    messages: {
	    	startDate: {
	           required: "请选择操作的起始日期!",
	           isDate10:"输入yyyy-mm-dd格式的日期"
	        },
	        endDate: {
		       required: "请选择操作的终止日期!",
        	   isDate10:"输入yyyy-mm-dd格式的日期",
		       compareDate:"终止日期必须大于起始日期"
		    }  
	    },
	    highlight: function (e) {
	        $(e).closest('.form-group').removeClass('has-info').addClass('has-error');
	    },
	    success: function (e) {
	        $(e).closest('.form-group').removeClass('has-error').addClass('has-info');
	        $(e).remove();
	    },
	    errorPlacement: function (error, element) {
	        error.insertAfter(element.parent());
	    }
});	

$("#query_btn").click(function(){ 
	//debugger;
	if (!$("#query_form").valid()) {
		alert("请检查表单是否正确填写");
	       return false;
	}
	$("#result_list_div").load("${ctx}/log/toLogList", $("#query_form").serialize());
}); 
		
function getLastMonth(date){
	var lastMonth =new Date(date.setMonth(date.getMonth() - 1));
	return lastMonth;
}
</script>
<div class="row">
	<div class="col-xs-12">	
		<div class="widget-box widget-color-blue2">			
			<div class="widget-header">
				<h5 class="widget-title">日志查询</h5>
				<div class="widget-toolbar">
					<a href="#" data-action="fullscreen" class="orange2"><i class="ace-icon fa fa-expand"></i></a>
					<a href="#" data-action="collapse"><i class="ace-icon fa fa-chevron-up"></i></a>
					<a href="#" data-action="close"><i class="ace-icon fa fa-times"></i></a>
				</div>
			</div>
			<div class="widget-body">
				<div class="widget-main no-padding">				
					<form class="form-horizontal" id="query_form" name="query_form">
						<fieldset>
						    <div class="row">
						    
						    	<div class="form-group col-xs-6">
									
									<label class="col-sm-3 control-label no-padding-left" for="title">日志标题</label>
									<div class="col-sm-9">
										<div class="clearfix">
											<input type="text" class="col-xs-10"  name="title" id="title"/>
										</div>
									</div>
								</div>
								<div class="form-group col-xs-6">
									
									<label class="col-sm-3 control-label no-padding-left" for="type">日志类型</label>
									<div class="col-sm-9">
										<div class="clearfix">
											
											<select class="col-xs-10 " id="type" name="type">
											<!-- <option value="">--请选择--</option> -->
											 <hw:dictOption dictType="D00047" value="" />
											</select>
										</div>
									</div>
								</div>
								<div class="form-group col-xs-6">
									
									<label class="col-sm-3 control-label no-padding-left" for="createBy">操作用户</label>
									<div class="col-sm-9">
										<div class="clearfix">
											<input type="text" class="col-xs-10"  name="createBy" id="createBy"/>
										</div>
									</div>
								</div>
								<div class="form-group col-xs-6">
									
									<label class="col-sm-3 control-label no-padding-left" for="requestMethod">请求方式</label>
									<div class="col-sm-9">
										<div class="clearfix">
											<select class="col-xs-10" id="requestMethod" name="requestMethod">
											 	<option value=""></option>
											 	<option value="GET">GET</option>
											 	<option value="POST">POST</option>
											
											</select>
											<!-- <input type="text" class="col-xs-10"  name="requestMethod" id="requestMethod"/>
										 --></div>
									</div>
								</div>
								<div class="form-group col-xs-6">
									<label class="col-sm-3 control-label no-padding-left" for="startDate">查询日期</label>
									<div class="col-sm-7">
										<div class="clearfix">
											<div class="input-daterange input-group">
												<input type="text"  class="form-control  col-xs-10" style="width: 220px;" name="startDate" id="startDate"/>
												<span class="input-group-addon">
													<i class="fa fa-exchange"></i>
												</span>
												<input type="text" class="form-control col-xs-10" style="width: 225px;" name="endDate" id="endDate"/>
											</div>
										</div>
									</div>
								</div>							
							</div>
						</fieldset>
						<div class="form-actions center">
							<button class="btn btn-sm btn-info" type="button" id="query_btn">
								<i class="icon-on-right ace-icon fa fa-search bigger-110"></i>
								查询
							</button>
							&nbsp; &nbsp; &nbsp;
							<button class="btn btn-sm" type="reset">
								<i class="ace-icon fa fa-refresh bigger-110"></i>
								重置
							</button>
						</div>		
					</form>
				</div>
			</div>
		</div>
	</div>
</div>
<br>
<div id="result_list_div"></div>


